package com.employees.action;



import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.employees.bean.EmployeeBase;

public class EmployeeEditData extends Action {
	



	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {


		EmployeeBase base=(EmployeeBase) form;
//		int SkillId=base.getSkillId();
//		int InfoId=base.getInfoId();
		String SkillId=request.getParameter("SkillId");
		String InfoId=request.getParameter("InfoId");
		String employeeNo=base.getEmployeeNo();
		String employeeName=base.getEmployeeName();
		String employeeBirthday=base.getEmployeeBirthday();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  //譬ｼ蠑丞喧譌ｶ髣ｴ
	    Date sDate=(Date) sdf.parse(employeeBirthday); //譬ｼ蠑丞喧startDate 蠑�ｧ区慮髣ｴ荳ｺ Date邀ｻ蝙�
		String employeeSex=base.getEmployeeSex();
		String employeeDepartment=base.getEmployeeDepartment();
		String employeeSkill=request.getParameter("employeeSkill");
		String[] array=employeeSkill.split(",");
		 for(int i=0;i<array.length;i++){
			 System.out.println("+++"+array[i]);
		 }
		
		 
		EmployeeBase emplyeeData=new EmployeeBase();
		emplyeeData.setSkillId(Integer.parseInt(SkillId));
		emplyeeData.setInfoId(Integer.parseInt(InfoId));
		emplyeeData.setEmployeeBirthday(employeeBirthday);
		emplyeeData.setEmployeeDepartment(employeeDepartment);
		emplyeeData.setEmployeeName(employeeName);
		emplyeeData.setEmployeeNo(employeeNo);
		emplyeeData.setEmployeeSex(employeeSex);
		
	
		request.setAttribute("emplyeeData", emplyeeData);
		request.setAttribute("array", array);
		
		return mapping.findForward("success");
		

	}

	
	
}
